home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The 640 MEG Shareware Studio 2
/
The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO
/
clang
/
tcclib.zip
/
WINDEMO.C
< prev
next >
Wrap
Text File
|
1989-01-02
|
3KB
|
146 lines
#include <conio.h>
#include <alloc.h>
#include <mem.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <time.h>
#include "window.h"
#define NUMWINDS 20
windowtype *windows[NUMWINDS+1];
windowtype *promptwindow;
main()
{
int i;
int left,right,top,bottom;
char title[]= "- Window XX -";
int win;
int color;
int ch;
/* randomize(); */
srand(3);
textattr(0x7);
clrscr();
for (i=0;i<20;i++)
cputs("This is a test of this program. This is not in a window\r\n");
for (i=0;i<NUMWINDS; i++)
{
top = random(10)+2;
left = random(58)+2;
bottom = top + 10;
right = left + 20;
do
{
color = random(127)+1;
}
while ( (color & 0xF) == ((color&0xF0) >> 4) );
title[9] = i/10+0x30;
title[10] = i%10+0x30;
if ( (windows[i] = makewindow(left,top,right,bottom,color,3,title))
== NULL)
{
switch(windowerr)
{
case WE_OMEM:
window(1,1,80,25);
cputs("Not enough memory to open window.\r\n");
return 1;
case WE_BADC:
window(1,1,80,25);
cputs("Bad coordinates for window.\r\n");
return 2;
default:
case WE_OK:
window(1,1,80,25);
cputs("Internal Error: makewindow\r\n");
return 5;
};
}
cputs("This is a test of this program.\r\n");
cputs("This is a test of this program.\r\n.");
}
promptwindow = makewindow(18,12,62,12,0x1E,2,"");
winwrite(promptwindow," Demonstration of Background Window Writing");
do
{
do
{
for ( i=0; i<NUMWINDS; i++)
winwrite(windows[i], "This is a test ");
}
while( !kbhit() );
ch = getch()-'0';
if ( ch >=0 && ch < NUMWINDS )
{
shiftwindow(windows[ch]);
shiftwindow(promptwindow);
}
else
break;
}
while (1);
deletewindow(promptwindow);
windows[NUMWINDS]=NULL;
for (i=0; i<NUMWINDS; i++)
{
#ifdef PROMPT
if ( (promptwindow = makewindow(20,12,60,12,0x1E,1," Delete Window ")
) == NULL )
{
window(1,1,80,25);
cputs("Not enough memory to make prompt window.\r\n");
return 1;
}
win = NUMWINDS;
while (windows[win] == NULL)
{
char buf[7];
clrscr();
cputs("Enter window number to delete: ");
buf[0] = 5;
cgets(buf);
win = atoi(&buf[2]);
if (win == -1)
exit(0);
}
deletewindow(promptwindow);
#else
win = i;
#endif
if ( shiftwindow(windows[win]) )
{
window(1,1,80,25);
cputs("Not enough memory available to shift to window\r\n");
return 1;
}
#ifdef PROMPT
getch();
#endif
if ( deletewindow(windows[win]) )
{
window(1,1,80,25);
cputs("Window %d is not the current window.\r\n");
return 1;
}
windows[win] = NULL;
}
return 0;
}